<div class="row">
	<div class="col-md-12">
		<ol class="breadcrumb">
			<li>
				<a href="#" onclick="toHome()">
					主页
				</a>
			</li>
			<li class="active">
				商品订单列表
			</li>
		</ol>
	</div>
</div>
<form role="form" class="form-horizontal">
	<div class="row page-cont">
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 cont-top">
			<div class="panel panel-white">
				<div class="panel-heading">
					<h4 class="panel-title">
						<span class="title-text">检索商品订单</span>
					</h4>
					<div class="panel-tools">
						<div class="dropdown">
							<a data-toggle="dropdown" class="btn btn-xs dropdown-toggle btn-transparent-grey">
								<i class="fa fa-cog"></i>
							</a>
							<ul class="dropdown-menu dropdown-light pull-right" role="menu">
								<li>
									<a class="panel-collapse collapses" href="#"><i class="fa fa-angle-up"></i> <span>折叠</span> </a>
								</li>
								<li>
									<a class="panel-expand" href="#">
										<i class="fa fa-expand"></i> <span>全屏</span>
									</a>
								</li>
							</ul>
						</div>
						<a class="btn btn-xs btn-link panel-close" href="#">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="panel-body">
					<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">交易流水号</label>
					    <div class="col-sm-4">
					      <input type="text" class="form-control" id="streamCode" />
					    </div>
				  	</div>
				  	<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">订单号</label>
					    <div class="col-sm-4">
					      <input type="text" class="form-control" id="orderCode" />
					    </div>
				  	</div>
				  	<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">商品名字</label>
					    <div class="col-sm-4">
					      <input type="text" class="form-control" id="orderName" />
					    </div>
				  	</div>
				  	<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">创建时间</label>
					    <div class="col-sm-4">
					      <input type="text" class="form-control" id="createDate" />
					    </div>
					    <span class="col-sm-4 tips">
					    	<i class="fa fa-info-circle"></i>
					    	*不包含最后一天
					    </span>
				  	</div>
					<div class="form-group panel-cont">
					    <label for="coupon" class="col-sm-2 control-label">状态</label>
					    <div class="col-sm-4">
					      	<select class="">
								<option value="">全部</option>
								<option value="WAIT">初始状态</option>
								<option value="PENDING_SEND">待发货</option>
								<option value="SELLER_SENT">卖家已发货</option>
								<option value="TRADE_SUCCESS">交易成功</option>
								<option value="PAY_FAILURE">支付失败</option>
								<option value="PAY_TIME_OUT">支付超时</option>
								<option value="CLOSED">交易关闭</option>
								<option value="REFUND">退款中</option>
								<option value="SUCCESS">支付成功</option>
							</select>
					    </div>
				  	</div>
				  	<div class="form-group">
				  		<div class="col-sm-5 col-sm-offset-5">
				  			<button type="button" class="btn btn-primary">查询</button>
				  			<button type="reset" class="btn reset-btn">重置</button>
				  		</div>
				  	</div>
				</div>
			</div>
		</div>
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 cont-bottom">
			<div class="panel panel-white">
				<div class="panel-heading">
					<h4 class="panel-title">
						<span class="title-text">商品订单列表</span>
					</h4>
					<div class="panel-tools">
						<div class="dropdown">
							<a data-toggle="dropdown" class="btn btn-xs dropdown-toggle btn-transparent-grey">
								<i class="fa fa-cog"></i>
							</a>
							<ul class="dropdown-menu dropdown-light pull-right" role="menu">
								<li>
									<a class="panel-collapse collapses" href="#"><i class="fa fa-angle-up"></i> <span>折叠</span> </a>
								</li>
								<li>
									<a class="panel-expand" href="#">
										<i class="fa fa-expand"></i> <span>全屏</span>
									</a>
								</li>
							</ul>
						</div>
						<a class="btn btn-xs btn-link panel-close" href="#">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="panel-body table-body">
					<table class="table table-bordered table-hover">
						<thead>
							<tr>
								<th class="hidden-xs">影院</th>
								<th class="hidden-xs">城市</th>
								<th class="hidden-xs">订单生成时间</th>
								<th class="hidden-xs">电影名称</th>
								<th class="hidden-xs">手机号</th>
								<th class="hidden-xs">支付价格</th>
								<th class="hidden-xs">购票总数</th>
								<th class="hidden-xs">支付状态</th>
								<th class="hidden-xs">订单号</th>
								<th class="hidden-xs">交易流水号</th>
								<th class="hidden-xs">操作</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div class="M-box3 page-style"></div>
				</div>
			</div>
		</div>
	</div>
</form>
<script>
	/**********************************************变量**********************************************/
	var pageNo = 1;    // 第几页
	var pageSize = 10;  // 每页几条
	var totalPage;     // 总页数
	var totalData;     // 总条数
	var startTime;     // 开始时间
	var endTime;       // 结束时间
	var username;      // 用户姓名
	var token = MXCookie.get("token",token);  // 登陆token;    

	/**********************************************事件**********************************************/
	datePicker($("#createDate"));  // 创建时间

	// getDate($("#startDate"));
	// getDate($("#endDate"));
	username = GetQueryString("username");

	// 查询
	function queryCoupon(){
		// if(checkMsg()){
		// 	alert("1");
		// }
	}

	/**********************************************函数**********************************************/
	// 订单列表
	function getList(){
		$("tbody").html("");
		$.ajax({
			url: localStorage.grobalUrl + "/order/orderList",
			type:"post",
			async:false,
			data:{
				username: username,
				token: token,
				pageNo: pageNo,   
				pageCount: pageSize				
			},
			success: function(data){
				console.log(data);
				
				var str = '<tr align="center">'+
							'<td class="film-name"></td>'+
							'<td class="city-name"></td>'+
							'<td class="create-time"></td>'+
							'<td class="movie-name"></td>'+
							'<td class="mobile"></td>'+
							'<td class="pay-price"></td>'+
							'<td class="ticket-num"></td>'+
							'<td>'+
								'<button type="button" class="btn btn-dark-yellow btn-xs pay-status"></button>'+
							'</td>'+
							'<td class="order-code"></td>'+
							'<td class="trade-code"></td>'+
							'<td>'+
								'<button type="button" class="btn btn-dark-yellow check-btn">查看&nbsp;<i class="fa fa-eye"></i></button>'+
							'</td>'+
						'</tr>';
				if(data.errCode == "00005"){
					tips("请重新登陆");
					setTimeout(function(){
						window.location.href = "login_login.html";
					},500);					
				}	
				if (data.list){
	  				var dataVal = data.list;
	  				totalPage = data.totalPage;	
	  				totalData = data.totalRow;		
	  				for(var i = 0; i < dataVal.length; i ++){
	  					$("tbody").append(str);
	  					var listVal = dataVal[i];
	  					$(".film-name").eq(i).text(listVal.cinema_name);
	  					$(".city-name").eq(i).text(listVal.city_name);
	  					$(".create-time").eq(i).text(listVal.create_time);
	  					$(".movie-name").eq(i).text(listVal.film_name);
	  					$(".mobile").eq(i).text(listVal.mobile);
	  					$(".ticket-num").eq(i).text(listVal.ticket_count);
	  					$(".pay-price").eq(i).text(listVal.pay_amount);
	  					if(listVal.status_pay == "PAY_TIME_OUT"){
	  						$(".pay-status").eq(i).text("");
	  					}else if(listVal.status_pay == "TRADE_SUCCESS"){
	  						$(".pay-status").eq(i).text("出票成功");
	  					}else if(listVal.status_pay == "PAY_FAILURE"){
	  						$(".pay-status").eq(i).text("支付失败");
	  					}else if(listVal.status_pay == "PAY_TIME_OUT"){
	  						$(".pay-status").eq(i).text("支付超时");
	  					}else if(listVal.status_pay == "CLOSED"){
	  						$(".pay-status").eq(i).text("支付关闭");
	  					}
	  					$(".order-code").eq(i).text(listVal.order_no);
	  					$(".trade-code").eq(i).text(listVal.trade_flowno);
	  				}
	  				// 查看优惠券详情
	  				toOperat($(".check-btn"),"view/orderManage/order-view.html");	
				}else{
				  $("tbody").append("<tr><td align='center' colspan='7'>暂无数据</td></tr>");
				}
			},
			error: function(err){
				console.log(err);
			}
		});
	}
	getList();

	// 分页
	pageSetGet();
	
</script>
